package bat.ke.qq.com.proxy;

import bat.ke.qq.com.dao.FoxDao;
import com.sun.corba.se.impl.ior.OldJIDLObjectKeyTemplate;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInterceptor;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 源码学院-Fox
 * 只为培养BAT程序员而生
 * http://bat.ke.qq.com
 * 往期视频加群:516212256 暗号:6
 */
@Slf4j
public class DynamicProxyHandler implements InvocationHandler {
	private Object target;

	public DynamicProxyHandler(Object target) {
		this.target = target;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

		Long  start = System.currentTimeMillis();
		Object result = method.invoke(target,args);
		log.info("调用时间：" +(System.currentTimeMillis()-start));
		return result;
	}
}
